package com.example.shop_2305

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.lib_base.mvvm.BaseViewActivity
import com.example.shop_2305.databinding.ActivityShopBinding

@Route(path = "/app/ShopActivity")
class ShopActivity : BaseViewActivity<ActivityShopBinding>() {
    @Autowired
    @JvmField
    var index = 0
    override fun initView() {
        ARouter.getInstance().inject(this)
        //联动 只能点击切换
        //找到导航宿主
      /*  val navHostFragment =
            supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
        //找到导航控制器
        val navController = navHostFragment.navController
        //和底部导航进行联动
        binding.bottom.setupWithNavController(navController)*/
        binding.bottom.setupWithNavController(findNavController(R.id.fragmentContainerView))


        when(index){
            0->{binding.bottom.selectedItemId = R.id.homeFragment}
            1->binding.bottom.selectedItemId = R.id.categoryFragment
            2->binding.bottom.selectedItemId = R.id.cartFragment
            3->binding.bottom.selectedItemId = R.id.mineFragment
        }

        requestPermissions(arrayOf("android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE"),100)

    }

    override fun initData() {

    }

    override fun getLayout(): Int  = R.layout.activity_shop

}